package org.shangrila.comm.utils;

import java.io.IOException;
import java.util.Enumeration;
import java.util.Properties;

public class PropUtil {
    /**
     * 从filePath解析key信息
     */
    public static String getVauleFromKey(String filePath,String key) {
		Properties prop = new Properties();
		try {
			prop.load(Class.class.getResourceAsStream(filePath));
			return prop.getProperty(key);
		} catch (IOException e) {
		}
		return null;
    }
    
    /**
     * 读取properties的全部信息
     */
    public static void getAllProperties(String filePath) {
     Properties props = new Properties();
        try {
        	props.load(Class.class.getResourceAsStream(filePath));
            Enumeration<?> en = props.propertyNames();
             while (en.hasMoreElements()) {
              String key = (String) en.nextElement();
                    String Property = props.getProperty (key);
                    System.out.println(key+"="+Property);
                }
        } catch (Exception e) {
         e.printStackTrace();
        }
    }
	
    
	public static void main(String[] args) {
		String file="/iptvws.ini";
		String attr="iptvwscrm.crm.bokong.flag";
		String ret=getVauleFromKey(file,attr);
		System.out.println(ret);	
		
		getAllProperties(file);
		
	}
	
 
}
